<?php

class PhpFox_Mod_Video_ComponentMyVideos extends BaseComponent
{
    function process()
    {
    	if ( !App::checkUserAccess('video', array('full', 'read_only'), false) )
		{
			return '';
		}

		$sType = $this->getParam('sType');
		$aItem = $this->getParam('aItem');

		if ( !$sType )
		{
			return '';
		}

		if ( $sType == 'profile' )
		{
			$iUserId = $this->getParam('userId');
			$aItem['user'] = $this->getParam('username');

			$aItems = $this->oDatabase->getRows("SELECT vid_id, vid_title FROM ". App::getT('videos') ."
				WHERE vid_userid = '". $iUserId ."'
				ORDER BY vid_time DESC LIMIT 0,6");
		}
		else
		{
			$aItems = $this->oDatabase->getRows("SELECT vid_id, vid_title FROM ". App::getT('videos') ."
				WHERE vid_userid = '". $aItem['vid_userid'] ."'
				ORDER BY vid_time DESC LIMIT 0,6");
		}

		if ( count($aItems) == 0 )
		{
			return '';
		}

		$this->oTpl->assign(array
		(
			'sGImageUrl' => App::getParam('video.image.url'),
			'sType' => $sType,
			'aDetail' => $aItem,
			'aItems' => $aItems,
		));

		return $this->oTpl->fetch('MyVideos.html');
	}

}

?>